package com.heyu.cloud.config;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.DefaultResourceLoader;

public class MybatisConstant {

	public static final Log log = LogFactory.getLog("mybatis");

	public static final String mybatisClassPathProp = "classpath:mybatis.properties";

	public static final String driverClassPathLibs = "classpath:drivers/";

	public static final String driverClass = "jdbc.driverClass";

	public static final String url = "jdbc.url";

	public static final String user = "jdbc.user";

	public static final String password = "jdbc.password";

	/**
	 * 获取mybatis文件配置
	 * 
	 * @param name
	 * @return
	 */
	public static final String getMybatisProperty(String name) {
		try {
			InputStream inputStream = new DefaultResourceLoader().getResource(mybatisClassPathProp).getInputStream();
			Properties properties = new Properties();
			properties.load(inputStream);
			inputStream.close();
			return properties.getProperty(name);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

}
